<div >
<?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'news-form',
    'enableAjaxValidation' => false,
    'enableClientValidation' => true,
    'htmlOptions' => array(
        'class' => 'form-horizontal',
    ),
));
?>

<?php if (Yii::app()->user->hasFlash('booked')): ?>
    <?php if (isset($user) && isset($model) && $model->id != null) : ?>
    <div class="nice-full-scroll">
        <div class="title-event">
            <h1><?php echo Yii::t('lang', 'event'); ?></h1>
        </div>
        
        <div class="event-thanks">
            <p class="title"><?php echo $main_event_tr['main_title']; ?></p>

            <p class="author"><?php echo $main_event_tr['sub_title']; ?></p>

            <div class="time"><p><?php echo date_format(new DateTime($event['start_time']), 'h:i A'); ?>
                    , <?php echo date_format(new DateTime($event['start_date']), 'd - m , Y'); ?></p></div>
            <div class="address">
                <p style="height:auto; "><?php echo $main_event_tr['location'] . ' , ' . $main_event_tr['address']; ?></p>
            </div>
        </div>
        <div class="title-event">
            <h1><?php echo Yii::t('lang', 'customer_info'); ?></h1>
        </div>
        <div class="info">
            <div class="info-ctn">
                <p>
                    <label><?php echo Yii::t('lang', 'name') ?>
                        :</label><?php if (isset($user)) : ?><?php echo $user->first_name . ' ' . $user->last_name; ?> <?php endif; ?>
                </p>

                <p>
                    <label>Email:</label><?php if (isset($model)) : ?><?php echo $model->email_contact; ?> <?php endif; ?>
                </p>

                <p>
                    <?php // var_dump($model['phone']);die();?>
                    <label><?php echo Yii::t('lang', 'phone') ?>:</label><?php echo $model->phone; ?>
                </p>

                <p>
                    <label><?php echo Yii::t('lang', 'address') ?>
                        :</label><?php if (isset($model)) : ?><?php echo $model->payment_address; ?> <?php endif; ?>
                </p>

                <p>
                    <label><?php echo Yii::t('lang', 'deliver_address') ?>
                        :</label><?php if (isset($model)) : ?><?php echo $model->deliver_address; ?> <?php endif; ?>
                </p>
            </div>


        </div>
        <div class="clear"></div>
        <div class="thankyou">

            <p><?php echo Yii::t('lang', 'thanks_contact'); ?></p>
        </div>
        </div>
        <!--                         </div>
                            </div>
                    </div> -->
    <?php else : ?>
        <div class="thankyou" style="margin-top:50px;">
            <p><?php echo Yii::t('lang', 'thanks_contact'); ?></p>
        </div>
    <?php endif; ?>
<?php else: ?>
    <!--         <div class="modal-dialog ticket-form" id="#Modal_Payment">
                <div class="modal-content"> -->
    <!-- <div class="ticket-form"> -->
    <div class="wiget_ticket">
        <div class="header-text">
            <h2><?php echo Yii::t('lang', 'booked_header'); ?></h2>
        </div>
        <p class="line"></p>

        <div class="ticket nice-scroll">


            <table class="table table-booked">
                <thead>
                <tr>
                    <th><span class="margin"><?php echo Yii::t('lang', 'ticket_name') ?></span></th>
                    <th><span class="margin"><?php echo Yii::t('lang', 'ticket_price') ?></span></th>
                    <th style="text-align: right;"><span class="margin"
                                                         style="margin-right: 50px"><?php echo Yii::t('lang', 'ticket_quantity') ?></span>
                    </th>
                </tr>
                </thead>
                <tbody>
                <?php if (count($event['tickets']) > 0): foreach ($event['tickets'] as $k => $ticket): ?>
                    <?php

                    $result = MyFunctionCustom::remain_quantity(null, $ticket['temp_quantity'], $ticket['remain_quantity']);
                    if ($result > 0) {
                        $result = true;
                    } else $result = false;
                    ?>
                    <?php

                    if ($result == true && $ticket['price'] > 0) :
//                            $ticket_price = CJSON::encode($ticket['price']);
//                            var_dump($k);
                        ?>
                        <tr>
                            <td style="position:relative;">
                                <?php $number_id = "checkbox-1-" . ($k + 1); ?>

                                <?php echo $form->checkBox($model, 'ticket_id[]', array('id' => $number_id, 'data-price' => $ticket['price'], 'class' => 'ticket-type regular-checkbox', 'checked' => false, 'value' => $ticket['id'], 'uncheckValue' => null)); ?>
                                <label for="checkbox-1-<?php echo $k + 1 ?>"></label>
                                <span><?php echo $ticket->description_of_ticket; ?></span>
                            </td>
                            <td class="price-popup"><?php echo number_format($ticket->price); ?> VNĐ
                                / <?php echo Yii::t('lang', 'ticket_text'); ?></td>
                            <td>
                                <div class="styled-select">
                                    <?php // echo $form->dropDownList($model, 'quantity[]', array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10)) ?>
                                    <?php echo CHtml::dropDownList("ticket[quantity][$ticket->id]", '', array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10), array('class' => 'select-ticket-number')); ?>
                                </div>
                            </td>
                        </tr>
                    <?php endif; ?>
                <?php endforeach;
                endif;
                ?>

                </tbody>

            </table>
            <div class="clear"></div>
            <div class="pull-right">
                <p class="total_price"><?php echo Yii::t('lang', 'total') ?> <span
                        class="total_price_num total_price"> </span></p>

            </div>
            <div class="clear"></div>
            <?php $seat_map = Ticket::model()->findByAttributes(array('event_id' => $event->id, 'seat_map' => 1)); ?>
            <?php if ($seat_map['pic_seat_map'] != null) : ?>

                <div style="text-align: center; margin-top: 10px">
                    <a href="#Modalseatmap" class="seat-map choose-seat" data-toggle="modal">
                        <?php echo Yii::t('lang', 'seat_map'); ?>
                    </a>
                </div>
            <?php endif; ?>
            <div class="wiget_notic">
                <p>
                    <?php echo Yii::t('lang', 'text_notification'); ?>
                    <?php if (isset($message)) { ?>

                    <div class="text-payment">
                        <p style="color:red;"><?php echo $message; ?></p>
                    </div>
                    <div class="clear"></div>
                    <?php } ?>
                    <?php echo $form->error($model, 'ticket_id'); ?>
                    <?php echo $form->error($model, 'payment_type'); ?>
                    <?php echo $form->error($model, 'phone'); ?>
                    <?php echo $form->error($model, 'email_contact'); ?>
                </p>
            </div>
            <div class="wiget_pay">
                <p><?php echo Yii::t('lang', 'book_payment'); ?></p>
                <?php echo $form->radioButtonlist(
                    $model,
                    'payment_type',
                    array(1 => Yii::t('lang', 'cod'), 2 => Yii::t('lang', 'credit_card'), 3 => Yii::t('lang', 'atm')),
                    array(
                        'template' => '{input}{label}',
                        'separator' => '',
                        'class' => 'css-checkbox',
                        'labelOptions' => array(
                            'class' => 'css-label',

                        )
                    ));
                ?>
            </div>
            <div class="row ticket-input-widget">
                <div class="col-sm-12">
                    <div class="col-sm-6">
                        <div class="control-group">
                            <?php echo $form->label($model, 'phone') ?>
                            <div class="clear"></div>
                            <?php echo $form->textField($model, 'phone', array('class' => 'form-control tk-phone-input', 'placeholder' => Yii::t('lang', 'phone'))); ?>

                        </div>
                        <div class="clear"></div>
                        <div class="control-group">
                            <?php echo $form->label($model, 'payment_address') ?>
                            <div class="clear"></div>
                            <?php echo $form->textField($model, 'payment_address', array('class' => 'form-control', 'placeholder' => Yii::t('lang', 'payment'))); ?>
                        </div>
                        <div class="clear"></div>
                        <div class="control-group">
                            <?php echo $form->label($model, 'deliver_address') ?>
                            <div class="clear"></div>
                            <?php echo $form->textField($model, 'deliver_address', array('class' => 'form-control', 'placeholder' => Yii::t('lang', 'deliver_address'))); ?>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="control-group">
                            <?php echo $form->label($model, 'email_contact'); ?>
                            <div class="clear"></div>
                            <?php echo $form->textField($model, 'email_contact', array('class' => 'form-control','placeholder' => Yii::t('lang','email_contact_placeholder'))); ?>
                        </div>
                        <div class="control-group">
                            <?php echo $form->label($model, 'additional_note', array('style' => 'margin-bottom:5px;float:left;')) ?>
                            <div class="clear"></div>
                            <?php echo $form->textArea($model, 'additional_note', array('class' => 'form-control', 'style' => 'min-height:95px;max-height:100px;')); ?>
                        </div>
                        <div class="control-group wiget_footer">
                            <a type="submit"
                               class="seat-map book ajax-submit-btn btn-continue"><?php echo Yii::t('lang', 'submit') ?></a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="clear">
            </div>


            <br/>

        </div>
    </div>
    <div class="modal modal-seatmap fade" id="Modalseatmap" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content login-modal">
                <div class="modal-header">
                    <button  type="button" class="close close-seatmap"><img
                            src="<?php echo Yii::app()->theme->baseUrl; ?>/frontend/images/icon_close.png"/></button>
                </div>
                <div class="modal-body">
                    <div>
                        <div class="header-text">
                            <h2 style="float: left;text-transform:uppercase"><?php echo Yii::t('lang', 'pick_seat'); ?></h2>
                        </div>
                        <div class="clear"></div>
                        <p class="line"></p>

                        <div class="clear"></div>
                        <div class="seatmap-nice-scroll">
                            <div class="col-sm-12">
                                <div class="col-sm-6">
                                    <?php // if (isset($_GET['ticket_id'])) : ?>
                                    <table class="table table-booked">
                                        <thead>
                                        <tr>
                                            <th><?php echo Yii::t('lang', 'ticket_name') ?></th>
                                            <th><?php echo Yii::t('lang', 'position') ?></th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <?php foreach ($event->tickets as $key => $value) : ?>
                                            <tr>
                                                <?php // $ticket = Ticket::model()->findByPk($value); ?>
                                                <?php

                                                $result = MyFunctionCustom::remain_quantity(null, $value['temp_quantity'], $value['remain_quantity']);
                                                if ($result > 0) {
                                                    $result = true;
                                                } else $result = false;
                                                ?>
                                                <?php if ($result == true) { ?>
                                                    <td class="price-popup"><?php echo $value->description_of_ticket; ?></td>
                                                    <td><input class="text-seat" type="text"
                                                               name="Ticket[seat][<?php echo $value->id; ?>]"/></td>
                                                <?php } ?>
                                            </tr>
                                        <?php endforeach; ?>
                                        </tbody>
                                    </table>
                                    <?php // endif;?>
                                </div>
                                <div class="col-sm-6">
                                    <div class="pull_right">
                                        <ul class="text-ticket">
                                            <?php // $text_ticket = Translate::model()->findByPk($_GET['event']); ?>
                                            <?php if ($main_event_tr->text_ticket != null) { ?>
                                                <li>

                                                    <p style="color:#fc8825"><?php echo $main_event_tr->text_ticket; ?></p>
                                                </li>
                                            <?php } ?>
                                            <br/>
                                            <li>
                                                <p style="line-height:20px !important;">
                                                    <?php echo Yii::t('lang', 'text_seat'); ?>

                                                <p style="line-height:20px !important;">
                                                    <?php echo Yii::t('lang', 'example'); ?>
                                                </p>
                                                </p>


                                            </li>
                                        </ul>

                                    </div>
                                    <div class="continue-book wiget_footer">
                                        <a class="book seat-map close-seatmap btn-continue">
                                            <?php echo Yii::t('lang', 'seat_continue'); ?>
                                        </a>
                                    </div>
                                </div>
                            </div>

                            <div class="clear"></div>


                            <div class="img-seat">
                                <img
                                    src="<?php echo Yii::app()->baseUrl . '/timthumb.php?src=' . Yii::app()->baseUrl . '/data/pic/' . $seat_map['pic_seat_map'] . '&w=750'; ?>">
                            </div>
                        </div>
                    </div>
                    <script type="text/javascript">
                        
                    </script>
                    <!-- <div class="text_info">

                    </div> -->
                </div>
            </div>
        </div>
    </div>








    <!--                 </div>
</div> -->
    <!-- </div> -->
<?php endif; ?>
<?php $this->endWidget(); ?>

<style>
.margin {
    margin-left: 20px;
}

.errorMessage {
    color: red;
    font-size: 15px;
    padding: 2px;
}

    /******** BORDER ********/
.ticket-form {
    width: auto;
    padding: 0;
    margin-right: 0;
    margin-left: 0;
}

.thanks-popup {
    width: auto;
    padding: 0;
    margin-right: 0;
    margin-left: 0;
}

.payment-deliver {
    width: auto;
    padding: 0;
    margin-right: 0;
    margin-left: 0;
}

.table {
    width: 100%;
}

.table-booked thead th:first-child {
    -webkit-border-top-left-radius: 5px;
    border-top-left-radius: 5px;
    -moz-border-top-left-radius: 5px;
    -webkit-border-bottom-left-radius: 5px;
    border-bottom-left-radius: 5px;
    -moz-border-bottom-left-radius: 5px;
}

.table-booked thead th:last-child {
    -webkit-border-top-right-radius: 5px;
    border-top-right-radius: 5px;
    -moz-border-top-right-radius: 5px;
    -webkit-border-bottom-right-radius: 5px;
    border-bottom-right-radius: 5px;
    -moz-border-bottom-right-radius: 5px;
}

.table-booked tbody tr {
    border-top: none;
    border-bottom: 1px solid #e5e5e5;
}

.table-booked thead tr {
    border: none;
}

.table-booked thead th {
    color: #fff;
    font-weight: normal;
    font-size: 18px;
    margin-left: 20px;
    /*text-align: center;*/
}

.table > tbody > tr > td {
    border-top: 0px solid #fff;
    /*text-align: center;*/
}

.table > thead > tr > th {
    border-bottom: 0;
}

.ticket-form th {
    font-size: 14px;
    padding-top: 5px;
    text-transform: uppercase;
    color: #666;
}

.ticket-form td {
    color: #666;

}

td.price-popup {
    color: #fc666a;
    font-size: 16px;
    font-weight: bold;
    /*float: right;*/
    padding-bottom: 8px;
}

.ticket-phone label, .additional-note label {
    margin-bottom: 5px;
    float: left;
    line-height: 28px;
    width: 150px;
    text-transform: uppercase;
    color: #666;
    padding-right: 5px;
}

.control-group, .text-payment {
    padding-top: 5px;
}

.text-payment p {
    margin-bottom: 5px;
    float: left;
    line-height: 28px;
    text-transform: uppercase;
    color: #666;
}

button.send-book {
    background: #303030;
    width: 70px;
    height: 2.8em;
    margin-top: -0.2em;
    color: #fff;
    display: block;
    text-align: center;
    text-transform: uppercase;
    text-decoration: none;
    font-size: 12px;
    float: left;
    -webkit-border-radius: 2px;
    -moz-border-radius: 2px;
    border-radius: 2px
}

.control-group input[type="text"] {
    padding: 10px;
    margin-top: 5px;
}

.payment-deliver div.modal-content {
    height: auto;
}

.booked-event h1 {
    font-size: 30px;
    text-align: center;
}

.booked-event .title {
    font-size: 20px;
}

.booked-event .author {
    font-size: 15px;
    color: #666;
    height: auto;
    border: none;
}

.booked-event .view-item {
    border: none;
    margin-bottom: 0;
    padding-bottom: 0;
    width: auto;
    bottom: inherit;
    margin: 0;
}

.booked-event {
    padding: 7px;
}

.booked-event .info {
    color: #666;
    text-transform: uppercase;
    font-size: 12px;
}

.booked-event .info p {
    font-size: 14px;
    font-family: 'open_sansregular', arial, sans-serif !important;
    padding: 7px 0;
}

.booked-event .info label {
    width: 95px;
}

#Modalseatmap .modal-dialog {
    width: 500px;
    height: 600px;
}

.ticket {
    font-family: sans-serif;
}

.title-event {
    margin-top: 30px;
}

.title-event h1 {
    color: #1474b4;
    text-transform: capitalize;
    font-size: 20px;
}

.event-thanks, .info, .thankyou {
    margin-top: 5px;
    background-color: #f3f3f3;
    border: 1px solid #e5e5e5;
}

.event-thanks .title {
    color: black;
    text-transform: capitalize;
    font-size: 21px;
    font-weight: bold;
    margin: 10px 20px;
    padding: 20px 15px 0;
}

.event-thanks .author {
    text-transform: capitalize;
    font-size: 20px;
    font-weight: bold;
    margin: 10px 20px;
    padding: 5px 15px 0;
}

.event-thanks .time, .event-thanks .address {
    margin-left: 35px;
    border: none !important;
}

.info-ctn {
    margin-left: 35px;

}

.info-ctn p label {
    font-family: "Helvetica";
    font-size: 15px;
    text-transform: capitalize;
    font-weight: normal;
}

.pull-right > p.total_price {
    color: #1474b4;
    font-family: "Helvetica-Light";
    font-size: 18px;
    font-weight: bold;
    width: 241px;
    text-transform: uppercase;
}

.ticket-input-widget {
    margin-top: 20px;
    font-family: "Helvetica-Light";
    font-size: 17px;
}
</style>
<script type="text/javascript">
    function getTotalPrice() {
        total = 0;
        $('.ticket-type').each(function () {
            if ($(this).is(":checked")) {
                price = $(this).attr('data-price');
                quantity = $(this).parent().parent().find(".select-ticket-number").get(0).value;

                total += price * quantity;
            }
        })

        $('.total_price_num').html(number_format(total) + " VND");
    }

    $('.select-ticket-number').change(getTotalPrice);
    $('.ticket-type').change(getTotalPrice);
</script>
</div>
